import { sm2 } from 'sm-crypto'

const SM2_PUBLICK_KEY = '04d1fde754174be00a1086a6ee369cff0e408a7320c23a05deb2ef3b23e0c9d130eb0065844c9491beff8501ad5255ba863d484503d9a683359bfcaa356e2a47b4'
const SM2_PRIVATE_KEY = '738329f9f39bd7d6c44e64c00eaa73420c1892d0a2069030ac0d447d9538f6d3'

/**
 * sm2加密
 * @param data
 * @returns {*}
 */
export function sm2Encrypt(data) {
  return sm2.doEncrypt(data, SM2_PUBLICK_KEY, 1)
}

/**
 * sm2解密
 * @param data
 * @returns {[]|string|string}
 */
export function sm2Decrypt(data) {
  return sm2.doDecrypt(data, SM2_PRIVATE_KEY, 1)
}
